package org.noidler.codex;

import com.mongodb.MongoClientSettings;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;

import java.util.Collections;

public class MongoDbClient {
    private MongoClient mongoClient;

    public MongoDbClient() {

        ServerAddress seed1 = new ServerAddress("localhost", 27017);
        MongoClientSettings settings = MongoClientSettings.builder()
                .applyToClusterSettings(builder ->
                        builder.hosts(Collections.singletonList(seed1)))
                .build();

        mongoClient = MongoClients.create(settings);
    }

    public void close() {
        mongoClient.close();
    }

    public MongoClient getMongoClient() {
        return mongoClient;
    }
}
